package com.esl.model.admin;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.esl.dto.admin.User_Dto;

@Entity
@Table(name = "T_User")
@Cache(usage=CacheConcurrencyStrategy.READ_ONLY) 
public class User implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6916637483170163425L;
	private Integer id;
	private String name;
	private String password;
	private Boolean sex;
	private String clas;
	private String phone;
	private String qq;
	private String email;
	private String interest;
	private String picurl;
	private String grade;
	private String state;
	private String studentNO;
	private Group group;
	private Role role;

	public User_Dto toDto(){
		return new User_Dto(studentNO, password, name, id);
	}
	
	
public User() {
		super();
	}


public User(String password, String email, String studentNO) {
		super();
		this.password = password;
		this.email = email;
		this.studentNO = studentNO;
	}

/*-------------------------------*/	
	@ManyToOne
	@JoinColumn(name = "r_rid")
	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	@ManyToOne
	@JoinColumn(name = "g_gid")
	public Group getGroup() {
		return group;
	}

	public void setGroup(Group group) {
		this.group = group;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "u_id", unique = true, nullable = false)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "u_name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "u_password")
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "u_sex")
	public Boolean isSex() {
		return sex;
	}

	public void setSex(Boolean sex) {
		this.sex = sex;
	}

	@Column(name = "u_clas")
	public String getClas() {
		return clas;
	}

	public void setClas(String clas) {
		this.clas = clas;
	}

	@Column(name = "u_phone")
	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	@Column(name = "u_qq")
	public String getQq() {
		return qq;
	}

	public void setQq(String qq) {
		this.qq = qq;
	}

	@Column(name = "u_email")
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Column(name = "u_interest")
	public String getInterest() {
		return interest;
	}

	public void setInterest(String interest) {
		this.interest = interest;
	}

	@Column(name = "u_picurl")
	public String getPicurl() {
		return picurl;
	}

	public void setPicurl(String picurl) {
		this.picurl = picurl;
	}

	@Column(name = "u_grade")
	public String getGrade() {
		return grade;
	}

	public void setGrade(String grade) {
		this.grade = grade;
	}

	@Column(name = "u_state")
	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	@Column(name = "u_studentNO")
	public String getStudentNO() {
		return studentNO;
	}

	public void setStudentNO(String studentNO) {
		this.studentNO = studentNO;
	}

}
